//
//  CustomButtonView.m
//  MobileShoppingMall
//
//  Created by 冯传昌 on 2021/4/26.
//  Copyright © 2021 冯传昌. All rights reserved.
//

#import "CustomButtonView.h"

@interface CustomButtonView()<UIGestureRecognizerDelegate>

@property (nonatomic,strong) UIImageView *imgV;

@property (nonatomic,strong) UILabel *textLB;

@end

@implementation CustomButtonView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addSubview:self.imgV];
        [self addSubview:self.textLB];
        
        self.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
        tap.delegate = self;
        [self addGestureRecognizer:tap];
    }
    return self;
}

- (void)setImage:(UIImage *)image{
    _image = image;
    self.imgV.image = _image;
}
- (void)setTextStr:(NSString *)textStr{
    _textStr = textStr;
    self.textLB.text = _textStr;
}

- (UIImageView *)imgV{
    if (!_imgV) {
        _imgV = [[UIImageView alloc] initWithFrame:CGRectMake(8, 0, 24, 24)];
    }
    return _imgV;
}

- (UILabel *)textLB{
    if (!_textLB) {
        _textLB = [[UILabel alloc] initWithFrame:CGRectMake(0, 27, 40, 13)];
        _textLB.textAlignment = NSTextAlignmentCenter;
        _textLB.font = FontSet(11);
        _textLB.textColor = MainBlackTextColor;
    }
    return _textLB;
}



#pragma mark - SEL
-(void)tapClick:(UIGestureRecognizer *)ges{
    if (self.touchBlock) {
        self.touchBlock();
    }
}

@end
